VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "msdatgrd.ocx"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmBasicARCashInvoice 
   BackColor       =   &H00F7D9C2&
   BorderStyle     =   0  'None
   Caption         =   "Form1"
   ClientHeight    =   9000
   ClientLeft      =   0
   ClientTop       =   -45
   ClientWidth     =   11580
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   9000
   ScaleWidth      =   11580
   ShowInTaskbar   =   0   'False
   Begin VB.Timer Timer1 
      Left            =   480
      Top             =   3240
   End
   Begin ITGControls.ITGTab SSTab1 
      Height          =   5040
      Left            =   30
      TabIndex        =   38
      Top             =   30
      Width           =   11280
      _ExtentX        =   19897
      _ExtentY        =   8890
      TabCount        =   2
      TabCaption(0)   =   "               Main               "
      TabContCtrlCnt(0)=   1
      Tab(0)ContCtrlCap(1)=   "ComunionFrames1"
      TabCaption(1)   =   "               List               "
      TabContCtrlCnt(1)=   1
      Tab(1)ContCtrlCap(1)=   "dtgList"
      TabTheme        =   2
      ActiveTabBackStartColor=   16250865
      ActiveTabBackEndColor=   16243138
      InActiveTabBackStartColor=   16243138
      InActiveTabBackEndColor=   16243138
      BeginProperty ActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty InActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      OuterBorderColor=   4210752
      TopLeftInnerBorderColor=   4210752
      BottomRightInnerBorderColor=   4210752
      DisabledTabBackColor=   -2147483633
      DisabledTabForeColor=   -2147483631
      Begin MSDataGridLib.DataGrid dtgList 
         Height          =   4730
         Left            =   -75000
         TabIndex        =   37
         Top             =   315
         Width           =   11280
         _ExtentX        =   19897
         _ExtentY        =   8334
         _Version        =   393216
         AllowUpdate     =   0   'False
         AllowArrows     =   -1  'True
         Appearance      =   0
         HeadLines       =   1
         RowHeight       =   15
         TabAction       =   2
         FormatLocked    =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   8
         BeginProperty Column00 
            DataField       =   "cInvNo"
            Caption         =   "Invoice No."
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "dDate"
            Caption         =   "Date"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   3
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "cCode"
            Caption         =   "Customer ID"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "cType"
            Caption         =   "Invoice Type"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   "cSMan"
            Caption         =   "Salesman ID"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column05 
            DataField       =   "cMSCode"
            Caption         =   "Market Segment"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column06 
            DataField       =   "nGross"
            Caption         =   "Gross"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column07 
            DataField       =   "cRemarks"
            Caption         =   "Remarks"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            AllowRowSizing  =   0   'False
            BeginProperty Column00 
               ColumnAllowSizing=   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   1319.811
            EndProperty
            BeginProperty Column01 
               Locked          =   -1  'True
               ColumnWidth     =   1154.835
            EndProperty
            BeginProperty Column02 
               Locked          =   -1  'True
               ColumnWidth     =   1289.764
            EndProperty
            BeginProperty Column03 
               Locked          =   -1  'True
               ColumnWidth     =   1289.764
            EndProperty
            BeginProperty Column04 
               Locked          =   -1  'True
               ColumnWidth     =   1305.071
            EndProperty
            BeginProperty Column05 
               Locked          =   -1  'True
               ColumnWidth     =   1365.165
            EndProperty
            BeginProperty Column06 
               Alignment       =   1
               Locked          =   -1  'True
               ColumnWidth     =   1260.284
            EndProperty
            BeginProperty Column07 
               Locked          =   -1  'True
               ColumnWidth     =   2459.906
            EndProperty
         EndProperty
      End
      Begin ITGControls.ComunionFrames ComunionFrames1 
         Height          =   4720
         Left            =   0
         Top             =   315
         Width           =   11280
         _ExtentX        =   19897
         _ExtentY        =   8334
         BackColor       =   16243138
         FillColor       =   16243138
         RoundedCorner   =   0   'False
         Caption         =   "Sales Invoice Information"
         Alignment       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Begin VB.ComboBox cboATCCode 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   6.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   9450
            Style           =   2  'Dropdown List
            TabIndex        =   29
            Top             =   2725
            Visible         =   0   'False
            Width           =   1500
         End
         Begin VB.ComboBox cboTaxType 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   6.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   9450
            Style           =   2  'Dropdown List
            TabIndex        =   28
            Top             =   2375
            Width           =   1500
         End
         Begin VB.ComboBox cboPaymentType 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   6.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   9450
            Style           =   2  'Dropdown List
            TabIndex        =   27
            Top             =   2025
            Width           =   1500
         End
         Begin VB.ComboBox cboTerms 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   6.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   9450
            Style           =   2  'Dropdown List
            TabIndex        =   26
            Top             =   1675
            Width           =   1485
         End
         Begin VB.ComboBox cboIntTerms 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   6.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   9450
            Style           =   2  'Dropdown List
            TabIndex        =   25
            Top             =   1325
            Width           =   1485
         End
         Begin VB.ComboBox cboDocType 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   6.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            ItemData        =   "frmBasicARCashInvoice.frx":0000
            Left            =   9450
            List            =   "frmBasicARCashInvoice.frx":0002
            Style           =   2  'Dropdown List
            TabIndex        =   24
            Top             =   975
            Width           =   1485
         End
         Begin VB.TextBox txtRemarks 
            Appearance      =   0  'Flat
            BorderStyle     =   0  'None
            DataField       =   "cLongDesc"
            Height          =   990
            Left            =   1560
            MaxLength       =   1000
            MultiLine       =   -1  'True
            TabIndex        =   17
            Top             =   2455
            Width           =   6050
         End
         Begin VB.CommandButton cmdPickMS 
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   3080
            Picture         =   "frmBasicARCashInvoice.frx":0004
            Style           =   1  'Graphical
            TabIndex        =   6
            Top             =   1185
            Width           =   315
         End
         Begin VB.CommandButton cmdPickCode 
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   3080
            Picture         =   "frmBasicARCashInvoice.frx":014E
            Style           =   1  'Graphical
            TabIndex        =   3
            Top             =   870
            Width           =   315
         End
         Begin VB.CommandButton cmdPickSM 
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   3080
            Picture         =   "frmBasicARCashInvoice.frx":0298
            Style           =   1  'Graphical
            TabIndex        =   12
            Top             =   1815
            Width           =   315
         End
         Begin VB.CommandButton cmdPickPD 
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   3080
            Picture         =   "frmBasicARCashInvoice.frx":03E2
            Style           =   1  'Graphical
            TabIndex        =   9
            Top             =   1500
            Width           =   315
         End
         Begin VB.CommandButton cmdPickPC 
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   3080
            Picture         =   "frmBasicARCashInvoice.frx":052C
            Style           =   1  'Graphical
            TabIndex        =   15
            Top             =   2130
            Width           =   315
         End
         Begin ITGControls.ITGDateBox dtbDate 
            Height          =   285
            Left            =   9450
            TabIndex        =   1
            Tag             =   "Invoice Date"
            Top             =   555
            Width           =   1470
            _ExtentX        =   2593
            _ExtentY        =   503
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   ""
            SendKeysTab     =   -1  'True
            Mandatory       =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtName 
            Height          =   285
            Left            =   3390
            TabIndex        =   4
            TabStop         =   0   'False
            Top             =   870
            Width           =   4230
            _ExtentX        =   7355
            _ExtentY        =   503
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   4170
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtSMName 
            Height          =   285
            Left            =   3390
            TabIndex        =   13
            TabStop         =   0   'False
            Top             =   1815
            Width           =   4230
            _ExtentX        =   7355
            _ExtentY        =   503
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   4170
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtPaymentType 
            Height          =   285
            Left            =   8055
            TabIndex        =   40
            Tag             =   "cboPaymentType"
            Top             =   2025
            Width           =   2385
            _ExtentX        =   3995
            _ExtentY        =   503
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Payment Type"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   975
         End
         Begin ITGControls.ITGTextBox txtIntTerms 
            Height          =   285
            Left            =   8055
            TabIndex        =   41
            Tag             =   "cboIntTerms"
            Top             =   1320
            Width           =   2595
            _ExtentX        =   4366
            _ExtentY        =   503
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Internal Terms"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   1185
         End
         Begin ITGControls.ITGTextBox txtTerms 
            Height          =   285
            Left            =   8055
            TabIndex        =   42
            Tag             =   "cboIntTerms"
            Top             =   1675
            Width           =   2385
            _ExtentX        =   3995
            _ExtentY        =   503
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Actual Terms"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   975
         End
         Begin ITGControls.ITGTextBox txtMSDesc 
            Height          =   285
            Left            =   3390
            TabIndex        =   7
            TabStop         =   0   'False
            Top             =   1185
            Width           =   4230
            _ExtentX        =   7355
            _ExtentY        =   503
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   4170
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtPDDesc 
            Height          =   285
            Left            =   3390
            TabIndex        =   10
            TabStop         =   0   'False
            Top             =   1500
            Width           =   4230
            _ExtentX        =   7355
            _ExtentY        =   503
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   4170
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtPCDesc 
            Height          =   285
            Left            =   3390
            TabIndex        =   16
            TabStop         =   0   'False
            Top             =   2130
            Width           =   4230
            _ExtentX        =   7355
            _ExtentY        =   503
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   4170
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtDocType 
            Height          =   285
            Left            =   8055
            TabIndex        =   44
            Tag             =   "cboType"
            Top             =   975
            Width           =   2385
            _ExtentX        =   3995
            _ExtentY        =   503
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Document Type"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   975
         End
         Begin ITGControls.ITGTextBox txtInvNo 
            Height          =   285
            Left            =   165
            TabIndex        =   0
            Top             =   555
            Width           =   2880
            _ExtentX        =   4868
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "Invoice No."
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   1470
         End
         Begin ITGControls.ITGTextBox txtCode 
            Height          =   285
            Left            =   165
            TabIndex        =   2
            Top             =   870
            Width           =   2880
            _ExtentX        =   4868
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Customer"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   1470
            LinkForeColor   =   16711680
         End
         Begin ITGControls.ITGTextBox txtSMCode 
            Height          =   285
            Left            =   165
            TabIndex        =   11
            Top             =   1815
            Width           =   2880
            _ExtentX        =   4868
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Salesman"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   1470
            LinkForeColor   =   16711680
         End
         Begin ITGControls.ITGTextBox txtMSCode 
            Height          =   285
            Left            =   165
            TabIndex        =   5
            Top             =   1185
            Width           =   2880
            _ExtentX        =   4868
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Market Segment"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   1470
         End
         Begin ITGControls.ITGTextBox txtPDCode 
            Height          =   285
            Left            =   165
            TabIndex        =   8
            Top             =   1500
            Width           =   2880
            _ExtentX        =   4868
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Product Division"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   1470
         End
         Begin ITGControls.ITGTextBox txtPCCode 
            Height          =   285
            Left            =   165
            TabIndex        =   14
            Top             =   2130
            Width           =   2880
            _ExtentX        =   4868
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Profit Center"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelForeColor  =   0
            LabelWidth      =   1350
            TextBoxWidth    =   1470
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtTaxType 
            Height          =   285
            Left            =   8055
            TabIndex        =   45
            Tag             =   "cboPaymentType"
            Top             =   2375
            Width           =   2385
            _ExtentX        =   3995
            _ExtentY        =   503
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Tax Type"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   975
         End
         Begin ITGControls.ITGTextBox txtATCCode 
            Height          =   285
            Left            =   8055
            TabIndex        =   46
            Tag             =   "cboPaymentType"
            Top             =   2725
            Visible         =   0   'False
            Width           =   2385
            _ExtentX        =   3995
            _ExtentY        =   503
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "ATC Code"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   975
         End
         Begin ITGControls.ITGTextBox txtEWTRate 
            Height          =   285
            Left            =   8055
            TabIndex        =   30
            Tag             =   "cboPaymentType"
            Top             =   3080
            Width           =   2910
            _ExtentX        =   4921
            _ExtentY        =   503
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "EWT Rate"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   1500
         End
         Begin ITGControls.ITGTextBox txtBalance 
            Height          =   285
            Left            =   8055
            TabIndex        =   33
            TabStop         =   0   'False
            Top             =   4215
            Width           =   2910
            _ExtentX        =   4921
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Balance"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   1500
            Enabled         =   0   'False
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtCredit 
            Height          =   285
            Left            =   8055
            TabIndex        =   32
            TabStop         =   0   'False
            Top             =   3900
            Width           =   2910
            _ExtentX        =   4921
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Credit"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   1500
            Enabled         =   0   'False
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtDebit 
            Height          =   285
            Left            =   8055
            TabIndex        =   31
            TabStop         =   0   'False
            Top             =   3585
            Width           =   2910
            _ExtentX        =   4921
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Debit"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   1500
            Enabled         =   0   'False
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtPayment 
            Height          =   285
            Left            =   4700
            TabIndex        =   23
            TabStop         =   0   'False
            Top             =   4215
            Width           =   2910
            _ExtentX        =   4921
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Payment"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   1500
            Enabled         =   0   'False
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtReturns 
            Height          =   285
            Left            =   4700
            TabIndex        =   21
            TabStop         =   0   'False
            Top             =   3900
            Width           =   2910
            _ExtentX        =   4921
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Returns"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   1500
            Enabled         =   0   'False
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtGross 
            Height          =   285
            Left            =   4700
            TabIndex        =   19
            TabStop         =   0   'False
            Top             =   3585
            Width           =   2910
            _ExtentX        =   4921
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Gross"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   1500
            Enabled         =   0   'False
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtEWT 
            Height          =   285
            Left            =   1545
            TabIndex        =   22
            TabStop         =   0   'False
            Top             =   4215
            Width           =   2910
            _ExtentX        =   4921
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "EWT"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   1500
            Enabled         =   0   'False
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtVAT 
            Height          =   285
            Left            =   1545
            TabIndex        =   20
            TabStop         =   0   'False
            Top             =   3900
            Width           =   2910
            _ExtentX        =   4921
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "VAT"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   1500
            Enabled         =   0   'False
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtTaxable 
            Height          =   285
            Left            =   1545
            TabIndex        =   18
            TabStop         =   0   'False
            Top             =   3585
            Width           =   2910
            _ExtentX        =   4921
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Taxable Base"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1350
            TextBoxWidth    =   1500
            Enabled         =   0   'False
            LinkForeColor   =   0
         End
         Begin VB.Label Label2 
            BackColor       =   &H00F7D9C2&
            Caption         =   "Remarks"
            Height          =   285
            Left            =   165
            TabIndex        =   47
            Top             =   2445
            Width           =   1245
         End
         Begin VB.Label Label1 
            BackColor       =   &H00F7D9C2&
            Caption         =   "Date"
            Height          =   285
            Left            =   8080
            TabIndex        =   43
            Top             =   600
            Width           =   1305
         End
      End
   End
   Begin MSComctlLib.StatusBar sbRS 
      Align           =   2  'Align Bottom
      Height          =   285
      Left            =   0
      TabIndex        =   39
      Top             =   8715
      Width           =   11580
      _ExtentX        =   20426
      _ExtentY        =   503
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   5
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Alignment       =   1
            AutoSize        =   1
            Bevel           =   0
            Object.Width           =   7199
            MinWidth        =   2
         EndProperty
         BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel5 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin ITGControls.ComunionFrames ComunionFrames2 
      Height          =   3000
      Left            =   30
      Top             =   5055
      Width           =   11280
      _ExtentX        =   19897
      _ExtentY        =   5292
      FrameColor      =   4210752
      BackColor       =   16243138
      FillColor       =   16243138
      RoundedCorner   =   0   'False
      Caption         =   "Details"
      Alignment       =   0
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ThemeColor      =   5
      ColorFrom       =   16243138
      ColorTo         =   16250865
      Begin ITGControls.ITGTab ITGTab1 
         Height          =   2550
         Left            =   0
         TabIndex        =   34
         Top             =   450
         Width           =   11280
         _ExtentX        =   19897
         _ExtentY        =   4498
         TabCount        =   2
         TabCaption(0)   =   "               Items               "
         TabContCtrlCnt(0)=   9
         Tab(0)ContCtrlCap(1)=   "txtLongDesc"
         Tab(0)ContCtrlCap(2)=   "cboSI"
         Tab(0)ContCtrlCap(3)=   "ITGTextBox1"
         Tab(0)ContCtrlCap(4)=   "ITGTextBox2"
         Tab(0)ContCtrlCap(5)=   "ITGTextBox3"
         Tab(0)ContCtrlCap(6)=   "ITGTextBox4"
         Tab(0)ContCtrlCap(7)=   "ITGTextBox5"
         Tab(0)ContCtrlCap(8)=   "ITGTextBox6"
         Tab(0)ContCtrlCap(9)=   "dtgSI"
         TabCaption(1)   =   "               Payment               "
         TabContCtrlCnt(1)=   2
         Tab(1)ContCtrlCap(1)=   "cboCS_C"
         Tab(1)ContCtrlCap(2)=   "dtgPayment"
         TabTheme        =   2
         ActiveTabBackStartColor=   16250865
         ActiveTabBackEndColor=   16243138
         InActiveTabBackStartColor=   16243138
         InActiveTabBackEndColor=   16243138
         BeginProperty ActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty InActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         OuterBorderColor=   4210752
         TopLeftInnerBorderColor=   4210752
         BottomRightInnerBorderColor=   4210752
         DisabledTabBackColor=   -2147483633
         DisabledTabForeColor=   -2147483631
         Begin VB.TextBox txtLongDesc 
            Appearance      =   0  'Flat
            DataField       =   "cLongDesc"
            Height          =   1095
            Left            =   1515
            MaxLength       =   1000
            MultiLine       =   -1  'True
            TabIndex        =   57
            Top             =   840
            Visible         =   0   'False
            Width           =   4035
         End
         Begin VB.ComboBox cboSI 
            Height          =   315
            ItemData        =   "frmBasicARCashInvoice.frx":0676
            Left            =   375
            List            =   "frmBasicARCashInvoice.frx":0678
            Style           =   2  'Dropdown List
            TabIndex        =   56
            Top             =   1875
            Visible         =   0   'False
            Width           =   1395
         End
         Begin MSDataGridLib.DataGrid DataGrid1 
            Height          =   7770
            Left            =   -74955
            TabIndex        =   55
            Top             =   360
            Width           =   11790
            _ExtentX        =   20796
            _ExtentY        =   13705
            _Version        =   393216
            AllowUpdate     =   0   'False
            AllowArrows     =   -1  'True
            Appearance      =   0
            HeadLines       =   1
            RowHeight       =   15
            TabAction       =   2
            FormatLocked    =   -1  'True
            BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ColumnCount     =   8
            BeginProperty Column00 
               DataField       =   "cInvNo"
               Caption         =   "Invoice No."
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column01 
               DataField       =   "dDate"
               Caption         =   "Date"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "MM/dd/yyyy"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   3
               EndProperty
            EndProperty
            BeginProperty Column02 
               DataField       =   "cCode"
               Caption         =   "Customer ID"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column03 
               DataField       =   "cType"
               Caption         =   "Invoice Type"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column04 
               DataField       =   "cSMan"
               Caption         =   "Salesman ID"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column05 
               DataField       =   "cMSCode"
               Caption         =   "Market Segment"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column06 
               DataField       =   "nGross"
               Caption         =   "Gross"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   1
               EndProperty
            EndProperty
            BeginProperty Column07 
               DataField       =   "cRemarks"
               Caption         =   "Remarks"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            SplitCount      =   1
            BeginProperty Split0 
               AllowRowSizing  =   0   'False
               BeginProperty Column00 
                  ColumnAllowSizing=   -1  'True
                  Locked          =   -1  'True
                  ColumnWidth     =   1319.811
               EndProperty
               BeginProperty Column01 
                  Locked          =   -1  'True
                  ColumnWidth     =   1154.835
               EndProperty
               BeginProperty Column02 
                  Locked          =   -1  'True
                  ColumnWidth     =   1289.764
               EndProperty
               BeginProperty Column03 
                  Locked          =   -1  'True
                  ColumnWidth     =   1289.764
               EndProperty
               BeginProperty Column04 
                  Locked          =   -1  'True
                  ColumnWidth     =   1305.071
               EndProperty
               BeginProperty Column05 
                  Locked          =   -1  'True
                  ColumnWidth     =   1365.165
               EndProperty
               BeginProperty Column06 
                  Alignment       =   1
                  Locked          =   -1  'True
                  ColumnWidth     =   1260.284
               EndProperty
               BeginProperty Column07 
                  Locked          =   -1  'True
                  ColumnWidth     =   2459.906
               EndProperty
            EndProperty
         End
         Begin ITGControls.ITGTextBox ITGTextBox1 
            Height          =   285
            Left            =   8415
            TabIndex        =   54
            TabStop         =   0   'False
            Top             =   9960
            Width           =   2385
            _ExtentX        =   3995
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Balance"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1000
            TextBoxWidth    =   1325
            Enabled         =   0   'False
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox ITGTextBox2 
            Height          =   285
            Left            =   8415
            TabIndex        =   53
            TabStop         =   0   'False
            Top             =   9600
            Width           =   2385
            _ExtentX        =   3995
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Credit"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1000
            TextBoxWidth    =   1325
            Enabled         =   0   'False
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox ITGTextBox3 
            Height          =   285
            Left            =   8415
            TabIndex        =   52
            TabStop         =   0   'False
            Top             =   9240
            Width           =   2370
            _ExtentX        =   3969
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Debit"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1000
            TextBoxWidth    =   1310
            Enabled         =   0   'False
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox ITGTextBox4 
            Height          =   285
            Left            =   5640
            TabIndex        =   51
            TabStop         =   0   'False
            Top             =   9960
            Width           =   2385
            _ExtentX        =   3995
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Payment"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1000
            TextBoxWidth    =   1325
            Enabled         =   0   'False
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox ITGTextBox5 
            Height          =   285
            Left            =   5640
            TabIndex        =   50
            TabStop         =   0   'False
            Top             =   9600
            Width           =   2385
            _ExtentX        =   3995
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Returns"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1000
            TextBoxWidth    =   1325
            Enabled         =   0   'False
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox ITGTextBox6 
            Height          =   285
            Left            =   9060
            TabIndex        =   49
            TabStop         =   0   'False
            Top             =   7800
            Width           =   2385
            _ExtentX        =   3995
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Gross"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1000
            TextBoxWidth    =   1325
            Enabled         =   0   'False
            LinkForeColor   =   0
         End
         Begin MSDataGridLib.DataGrid dtgSI 
            Height          =   2230
            Left            =   0
            TabIndex        =   35
            Top             =   315
            Width           =   11280
            _ExtentX        =   19897
            _ExtentY        =   3942
            _Version        =   393216
            AllowUpdate     =   -1  'True
            AllowArrows     =   -1  'True
            Appearance      =   0
            BackColor       =   16777215
            HeadLines       =   1
            RowHeight       =   15
            TabAcrossSplits =   -1  'True
            TabAction       =   2
            FormatLocked    =   -1  'True
            BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ColumnCount     =   10
            BeginProperty Column00 
               DataField       =   "cItemNo"
               Caption         =   "Product ID"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column01 
               DataField       =   "cDesc"
               Caption         =   "Product Description"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column02 
               DataField       =   "cUnit"
               Caption         =   "Unit"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column03 
               DataField       =   "nQty"
               Caption         =   "Quantity"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   1
               EndProperty
            EndProperty
            BeginProperty Column04 
               DataField       =   "cPricing"
               Caption         =   "Pricing"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   "#,##0.00000000"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column05 
               DataField       =   "nUDPrice"
               Caption         =   "Price"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   1
               EndProperty
            EndProperty
            BeginProperty Column06 
               DataField       =   "cDiscount"
               Caption         =   "Discount"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column07 
               DataField       =   "nPrice"
               Caption         =   "Net Price"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   1
               EndProperty
            EndProperty
            BeginProperty Column08 
               DataField       =   "nAmount"
               Caption         =   "Amount"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   1
               EndProperty
            EndProperty
            BeginProperty Column09 
               DataField       =   "cWH"
               Caption         =   "Warehouse"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            SplitCount      =   1
            BeginProperty Split0 
               BeginProperty Column00 
                  Button          =   -1  'True
                  ColumnWidth     =   1154.835
               EndProperty
               BeginProperty Column01 
                  Button          =   -1  'True
                  Locked          =   -1  'True
                  ColumnWidth     =   2505.26
               EndProperty
               BeginProperty Column02 
                  Button          =   -1  'True
                  Locked          =   -1  'True
                  ColumnWidth     =   780.095
               EndProperty
               BeginProperty Column03 
                  Alignment       =   1
                  ColumnWidth     =   1019.906
               EndProperty
               BeginProperty Column04 
                  Button          =   -1  'True
                  Locked          =   -1  'True
                  Object.Visible         =   0   'False
                  ColumnWidth     =   989.858
               EndProperty
               BeginProperty Column05 
                  Alignment       =   1
                  ColumnWidth     =   1019.906
               EndProperty
               BeginProperty Column06 
                  Object.Visible         =   -1  'True
                  ColumnWidth     =   1080
               EndProperty
               BeginProperty Column07 
                  Alignment       =   1
                  Locked          =   -1  'True
                  Object.Visible         =   -1  'True
                  ColumnWidth     =   1110.047
               EndProperty
               BeginProperty Column08 
                  Alignment       =   1
                  Locked          =   -1  'True
                  Object.Visible         =   -1  'True
                  ColumnWidth     =   1289.764
               EndProperty
               BeginProperty Column09 
                  Button          =   -1  'True
                  Locked          =   -1  'True
                  Object.Visible         =   0   'False
                  ColumnWidth     =   1154.835
               EndProperty
            EndProperty
         End
         Begin VB.ComboBox cboCS_C 
            Height          =   315
            ItemData        =   "frmBasicARCashInvoice.frx":067A
            Left            =   -74880
            List            =   "frmBasicARCashInvoice.frx":067C
            Style           =   2  'Dropdown List
            TabIndex        =   48
            Top             =   1440
            Visible         =   0   'False
            Width           =   1035
         End
         Begin MSDataGridLib.DataGrid dtgPayment 
            Height          =   2230
            Left            =   -75000
            TabIndex        =   36
            Top             =   315
            Width           =   11280
            _ExtentX        =   19897
            _ExtentY        =   3942
            _Version        =   393216
            AllowUpdate     =   -1  'True
            AllowArrows     =   -1  'True
            Appearance      =   0
            BackColor       =   16777215
            HeadLines       =   1
            RowHeight       =   15
            TabAcrossSplits =   -1  'True
            TabAction       =   2
            FormatLocked    =   -1  'True
            BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ColumnCount     =   10
            BeginProperty Column00 
               DataField       =   "cType"
               Caption         =   "Type"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column01 
               DataField       =   "cAuthorization"
               Caption         =   "Authorization Code"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column02 
               DataField       =   "cCCardType"
               Caption         =   "Credit Card Type"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column03 
               DataField       =   "cBankID"
               Caption         =   "Bank ID"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column04 
               DataField       =   "cCCardNo"
               Caption         =   "Card Number"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column05 
               DataField       =   "dExpiration"
               Caption         =   "Expiration"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column06 
               DataField       =   "dDate"
               Caption         =   "Date"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column07 
               DataField       =   "nCash"
               Caption         =   "Cash"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column08 
               DataField       =   "nChange"
               Caption         =   "Change"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column09 
               DataField       =   "nAmount"
               Caption         =   "Amount"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   1
               EndProperty
            EndProperty
            SplitCount      =   1
            BeginProperty Split0 
               BeginProperty Column00 
                  Button          =   -1  'True
                  Locked          =   -1  'True
                  ColumnWidth     =   929.764
               EndProperty
               BeginProperty Column01 
               EndProperty
               BeginProperty Column02 
                  Button          =   -1  'True
                  Locked          =   -1  'True
                  ColumnWidth     =   1620.284
               EndProperty
               BeginProperty Column03 
                  Button          =   -1  'True
                  ColumnWidth     =   1335.118
               EndProperty
               BeginProperty Column04 
                  ColumnWidth     =   1590.236
               EndProperty
               BeginProperty Column05 
                  ColumnWidth     =   1124.787
               EndProperty
               BeginProperty Column06 
                  Object.Visible         =   0   'False
                  ColumnWidth     =   1094.74
               EndProperty
               BeginProperty Column07 
                  ColumnWidth     =   1260.284
               EndProperty
               BeginProperty Column08 
                  Object.Visible         =   0   'False
               EndProperty
               BeginProperty Column09 
                  Locked          =   -1  'True
                  ColumnWidth     =   1544.882
               EndProperty
            EndProperty
         End
      End
   End
End
Attribute VB_Name = "frmBasicARCashInvoice"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'xwelx 04.2010

Option Explicit

'Object variables
Private oPrint As New clsPrinting

'Recordset variables
Private WithEvents rsHeader As ADODB.Recordset
Attribute rsHeader.VB_VarHelpID = -1
Private rsDetail As ADODB.Recordset
Private rsPayment As ADODB.Recordset
Private rsCCard As ADODB.Recordset

'ADO Connection variables
Private connHeader As ADODB.Connection
Private connDetail As ADODB.Connection
Private connPayment As ADODB.Connection

'Form mode enumeration
Enum eBasicCIMode
    Normal
    AddNewEdit
    Find
End Enum
Public Mode As eBasicCIMode

'Other declarations
Private lLessAmount As Boolean
Private lLessPercent As Boolean
Private lNetOK As Boolean

Public dtgName As String
Public sBit As String
Private vBM As Variant 'Recordset bookmark variable
Private strNo As String, X As String

Dim aQty(0 To 999) As Double

Dim nSRP(0 To 999) As Double
Dim nWSP(0 To 999) As Double
Dim nNewQtyBoundary(0 To 999) As Double
Dim nPaid, nAmount, nPAmount, nCash As Double

'Security Acess Level variables
Public lACNew As Boolean
Public lACEdit As Boolean
Public lACDelete As Boolean
Public lACPost As Boolean
Public lACCancel As Boolean
Public lACPrint As Boolean

Dim sType As String
Private lSysTransDate As Boolean 'add by denz:2/17/2011 for transdate


Private Sub cboCS_C_Click()
    If dtgPayment.Col = 0 Then
        rsPayment!cType = cboCS_C
    ElseIf dtgPayment.Col = 2 Then
        rsPayment!cCCardType = cboCS_C
    End If
End Sub

Private Sub cboCS_C_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        If dtgPayment.Col = 0 Then
            rsPayment!cType = cboCS_C
            cboCS_C.Visible = False
            If rsPayment!cType = "CSH" Then
                dtgPayment.Col = 7
                dtgPayment.SetFocus
            Else
                dtgPayment.Col = 1
                dtgPayment.SetFocus
            End If
        ElseIf dtgPayment.Col = 2 Then
            rsPayment!cCCardType = cboCS_C
            cboCS_C.Visible = False
            dtgPayment.Col = 3
            dtgPayment.SetFocus
        End If
    ElseIf KeyCode = vbKeyEscape Then
        cboCS_C.Visible = False
    End If
End Sub

Private Sub cboCS_C_KeyPress(KeyAscii As Integer)
If Mode <> AddNewEdit Then Exit Sub
    If rsPayment.RecordCount = 0 Then Exit Sub
    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}
    If KeyAscii = 13 Then
        If rsPayment!cType = "CSH" Then
            cboCS_C.Visible = False
            dtgPayment.Col = 7
            dtgPayment.SetFocus
        End If
    Else
        KeyAscii = Asc(UCase(Chr(KeyAscii))) 'All Upper Case String
    End If
End Sub

Private Sub cboCS_C_LostFocus()
cboCS_C.Visible = False
End Sub

Private Sub cboPaymentType_Click()
    txtPaymentType = Trim(cboPaymentType)
End Sub

Private Sub cboPaymentType_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub

Private Sub cboSI_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        If dtgSI.Col = 4 Then
            rsDetail!cPricing = cboSI
            cboSI.Visible = False
            dtgSI.Col = 5
            dtgSI.SetFocus
        ElseIf dtgSI.Col = 2 Then
            rsDetail!cUnit = cboSI
            cboSI.Visible = False
            dtgSI.Col = 3
            dtgSI.SetFocus
        End If
    ElseIf KeyCode = vbKeyEscape Then
        cboSI.Visible = False
    End If
End Sub

Private Sub cboSI_LostFocus()
    cboSI.Visible = False
End Sub

Private Sub cboIntTerms_Click()
    txtIntTerms = Trim(cboIntTerms)
End Sub

Private Sub cboIntTerms_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub

Private Sub cboTerms_Click()
    txtTerms = Trim(cboTerms)
End Sub

Private Sub cboTerms_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub

Private Sub cboTaxType_Click()
    txtTaxType = Trim(cboTaxType)
End Sub

Private Sub cboTaxType_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub

Private Sub cboDocType_Click()
On Error GoTo TheSource
    txtDocType = Trim(cboDocType)
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtInvNo) = "" Then Exit Sub
    If rsHeader.Status <> adRecNew Then
        If ((Format(Right(txtInvNo, 5) - 1, X))) <> (strNo) Then Exit Sub
    End If
TheSource:
    Exit Sub
End Sub

Private Sub cboDocType_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub


Private Sub cboPaymentType_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If rsDetail.RecordCount = 0 Then TBNewLine
End Sub

'Call pick list module
Private Sub cmdPickCode_Click()
    If lPickListActive Then Exit Sub
    sFilterString = Trim(txtCode)
    frmITGPicker.zType = QCustomer
    'added condition
    frmITGPicker.Condition = "where cCompanyID = '" & COID & "'"
    
    frmITGPicker.Show vbModal
    rsHeader!cCode = frmITGPicker.zCode
    txtName = frmITGPicker.zName
End Sub

Private Sub cmdPickMS_Click()
    If lPickListActive Then Exit Sub
    sFilterString = Trim(txtMSCode)
    frmITGPicker.zType = QMarketSegment
    'added condition
    frmITGPicker.Condition = "AND cCompanyID = '" & COID & "'"
    
    frmITGPicker.Show vbModal
    txtMSCode.Text = frmITGPicker.zCode
    txtMSCode = frmITGPicker.zName
    If Trim(txtMSDesc) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub cmdPickPC_Click()
    If lPickListActive Then Exit Sub
    frmITGPicker.zType = QProfitCenter
    'added condition
    frmITGPicker.Condition = "where cCompanyID = '" & COID & "'"
    
    frmITGPicker.Show vbModal
    rsHeader!cPCCode = frmITGPicker.zCode
    If Trim(txtPCDesc) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub cmdPickPD_Click()
    If lPickListActive Then Exit Sub
    frmITGPicker.zType = QProductDivision
    'added condition
    frmITGPicker.Condition = "AND cCompanyID = '" & COID & "'"
    
    frmITGPicker.Show vbModal
    txtPDCode = frmITGPicker.zCode
    txtPDDesc = frmITGPicker.zName
    If Trim(txtPDDesc) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub cmdPickSM_Click()
    If lPickListActive Then Exit Sub
    sFilterString = Trim(txtSMCode)
    frmITGPicker.zType = QSalesman
    'added condition
    frmITGPicker.Condition = "where cCompanyID = '" & COID & "'"
    
    frmITGPicker.Show vbModal
    txtSMCode.Text = frmITGPicker.zCode
    txtSMName = frmITGPicker.zName
    If Trim(txtSMName) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub dtgList_HeadClick(ByVal ColIndex As Integer)
    SortGrid dtgList, ColIndex, rsHeader
End Sub

Private Sub dtgPayment_AfterColUpdate(ByVal ColIndex As Integer)
If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 7
            
            TotalAmount
            Do While IsNull(rsPayment!nCash) = True
                rsPayment.MovePrevious
            Loop
            If rsPayment!nCash > nAmount And nPAmount = 0 Then
                rsPayment!nChange = rsPayment!nCash - nAmount
                rsPayment!nAmount = nAmount
            ElseIf rsPayment!nCash = nAmount And nPAmount = 0 Then
                rsPayment!nChange = 0
                rsPayment!nAmount = rsPayment!nCash
            ElseIf rsPayment!nCash < nAmount And nPAmount = 0 Then
                rsPayment!nAmount = rsPayment!nCash
                rsPayment!nChange = 0
            ElseIf rsPayment!nCash < nAmount And nPAmount > 0 And rsPayment!nCash > (nAmount - nPAmount) Then
                rsPayment!nAmount = nAmount - nPAmount
                rsPayment!nChange = rsPayment!nCash - (nAmount - nPAmount)
            ElseIf rsPayment!nCash < nAmount And nPAmount > 0 And rsPayment!nCash < (nAmount - nPAmount) Then
                rsPayment!nAmount = rsPayment!nCash
                rsPayment!nChange = 0
            End If
            
    End Select
End Sub

Private Sub dtgPayment_ButtonClick(ByVal ColIndex As Integer)
If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 0 'Payment type
            Call LoadComboValues(cboCS_C, "cValue", "PARAMETER_USER", "WHERE cCompanyID = '" & COID & "' AND cType = 'PAYTYPE' and cParamName <> 'CHK'", "nOrder")
            Call MoveCombo(cboCS_C, dtgPayment, dtgPayment.Columns(0))
            ComboLoadValue cboCS_C, Trim(dtgPayment.Columns(0).Text)
        Case 2 'Credit card type
            Call LoadComboValues(cboCS_C, "cValue", "PARAMETER_USER", "WHERE cCompanyID = '" & COID & "' AND cType = 'CCARDTYPE'", "nOrder")
            Call MoveCombo(cboCS_C, dtgPayment, dtgPayment.Columns(2))
            ComboLoadValue cboCS_C, Trim(dtgPayment.Columns(2).Text)
        Case 3 'Bank ID
            If lPickListActive Then Exit Sub
            frmITGPickList.mType = Bank
            frmITGPickList.Show vbModal
            If Trim(frmITGPickList.mCode) = "" Then Exit Sub
            dtgPayment.Columns(3).Value = frmITGPickList.mName & ""
            If dtgPayment.Columns(1).Text <> "" And dtgPayment.Columns(3).Text <> "" Then
                If AuthorExisting(dtgPayment.Columns(1).Text, dtgPayment.Columns(3).Text, rsCCard, True) Then
                    MsgBox "Authorization already exist."
                    dtgPayment.Col = 3
                   Exit Sub
                End If
            End If
            dtgPayment.Col = 4
            dtgPayment.Columns(4).Value = rsPayment!cCCardNo
    End Select
End Sub

Private Sub dtgPayment_Click()
    If Mode = AddNewEdit Then dtgName = dtgPayment.Name
End Sub

Private Sub dtgPayment_Error(ByVal DataError As Integer, Response As Integer)
If Mode <> AddNewEdit Then
        Response = 0
        Exit Sub
    End If
    If DataError = 7007 Then
        MsgBox "Type mismatch", vbExclamation, msgTtl
    ElseIf DataError = 13 Then
        MsgBox "Type mismatch", vbExclamation, msgTtl
    End If
    Response = 0
End Sub

Private Sub dtgPayment_GotFocus()
    dtgName = dtgPayment.Name
End Sub

Private Sub dtgPayment_KeyDown(KeyCode As Integer, Shift As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If (Shift = vbCtrlMask And KeyCode = 45) Then
        TBNewLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 46) Then
        TBDeleteLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 83) Then
        TBSave
    End If
End Sub

Private Sub dtgPayment_KeyPress(KeyAscii As Integer)
If Mode <> AddNewEdit Then Exit Sub
    If rsPayment.RecordCount = 0 Then Exit Sub
    
    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}
    If KeyAscii = 13 Then
        Select Case dtgPayment.Col
            Case 0
                If Not cboCS_C.Visible Then dtgPayment_ButtonClick 0
                cboCS_C.SetFocus
                If rsPayment!cType = "CSH" Then
                    dtgPayment.Col = 7
                End If
            Case 1
                If dtgPayment.Columns(1).Text <> "" And dtgPayment.Columns(3).Text <> "" Then
                    If AuthorExisting(dtgPayment.Columns(1).Text, dtgPayment.Columns(3).Text, rsCCard, True) Then
                        MsgBox "Authorization already exist."
                        dtgPayment.Col = 1
                        Exit Sub
                    End If
                ElseIf Trim(dtgPayment.Columns(1).Text) = "" Then
                    MsgBox "Authorization Code is required."
                    dtgPayment.Col = 1
                    Exit Sub
                Else
                    SendKeys "{Tab}"
                End If
            Case 2
                If Not cboCS_C.Visible Then dtgPayment_ButtonClick 2
            Case 3
                dtgPayment_ButtonClick 3
                If dtgPayment.Columns(1).Text <> "" And dtgPayment.Columns(3).Text <> "" Then
                    If AuthorExisting(dtgPayment.Columns(1).Text, dtgPayment.Columns(3).Text, rsCCard, True) Then
                        MsgBox "Authorization already exist."
                        dtgPayment.Col = 3
                        Exit Sub
                    End If
                End If
            Case 4
                If Trim(dtgPayment.Columns(4).Text) = "" Then
                    MsgBox "Credit Card Number is required."
                    dtgPayment.Col = 4
                    Exit Sub
                Else
                    SendKeys "{Tab}"
                End If
            Case 5
                If rsPayment!cType = "CSH" Then
                    dtgPayment.Columns(5).Text = ""
                Else
                    dtgPayment.Columns(5).Text = Format(Date, "MM/dd/yyyy")
                End If
                SendKeys "{Tab}"
            Case 7
                dtgPayment_AfterColUpdate 7
                TBNewLine
                dtgPayment.Col = 0
            Case Else
                SendKeys "{Tab}"
        End Select
    Else
        KeyAscii = Asc(UCase(Chr(KeyAscii))) 'All Upper Case String
    End If
End Sub

Private Sub dtgPayment_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Mode <> AddNewEdit Then Exit Sub
    If Button = 2 Then
        dtgName = dtgPayment.Name
        PopupMenu ITGLedgerMain.mnuDetail
    End If
End Sub


'After column update
Private Sub dtgSI_AfterColUpdate(ByVal ColIndex As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 0
            If GetValueFrTable("cItemNo", "ITEM", "cItemNo = '" & Trim(dtgSI.Columns(0).Value) & "'") <> "" Then
                GetInitialItemValues
                dtgSI_ButtonClick 1
                dtgSI.Col = 2
                dtgSI.Columns(3).Value = rsDetail!nQty
            Else
                dtgSI_ButtonClick 0
            End If
        Case 3, 5, 6
            ComputeAll
            
        Case 7
             If rsPayment!nCash > nAmount Then
                rsPayment!nChange = rsPayment!nCash - nAmount
                rsPayment!nAmount = nAmount
            Else
                rsPayment!nChange = 0
                rsPayment!nAmount = rsPayment!nCash
            End If
    End Select
End Sub

Private Sub dtgSI_ButtonClick(ByVal ColIndex As Integer)
    If ColIndex = 1 Then
        If Mode <> Find Then
            Call MoveText(txtLongDesc, dtgSI, dtgSI.Columns(1))
            txtLongDesc = rsDetail!cLongDesc & ""
        End If
    End If
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 0
            If lPickListActive Then Exit Sub
            sFilterString = Trim(dtgSI.Columns(0).Text)
            frmITGPicker.zType = QProduct
            'added condition
            frmITGPicker.Condition = "where cCompanyID = '" & COID & "'"
            
            frmITGPicker.Show vbModal
            rsDetail!cItemNo = Trim(frmITGPicker.zCode) & ""
            
            If (Trim(frmITGPicker.zName) & "") <> "" Then
                dtgSI.Col = 2
                GetInitialItemValues
                dtgSI.Columns(3).Value = rsDetail!nQty
            End If
        Case 2
            If Trim(dtgSI.Columns(0).Text) = "" Then Exit Sub
            Call LoadUnitValues(cboSI, Trim(dtgSI.Columns(0).Text))
            Call MoveCombo(cboSI, dtgSI, dtgSI.Columns(2))
            ComboLoadValue cboSI, Trim(dtgSI.Columns(2).Text)
        Case 4
            Call LoadComboValues(cboSI, "cValue", "PARAMETER_SYSTEM", "WHERE cType = 'PRICING' and nOrder in (1,10,9,8)", "nOrder")
            Call MoveCombo(cboSI, dtgSI, dtgSI.Columns(4))
            ComboLoadValue cboSI, Trim(dtgSI.Columns(4).Text)
    End Select
End Sub

Private Sub dtgSI_Click()
    If Mode = AddNewEdit Then dtgName = dtgSI.Name
End Sub

Private Sub dtgSI_Error(ByVal DataError As Integer, Response As Integer)
    Response = 0
End Sub

Private Sub dtgSI_KeyDown(KeyCode As Integer, Shift As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If (Shift = vbCtrlMask And KeyCode = 45) Then
        TBNewLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 46) Then
        TBDeleteLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 83) Then
        TBSave
    ElseIf (Shift = vbCtrlMask And KeyCode = vbKeyTab) Then
        dtgPayment.SetFocus
    End If
End Sub

Private Sub dtgSI_KeyPress(KeyAscii As Integer)
    
    If Mode <> AddNewEdit Then Exit Sub
    If rsDetail.RecordCount = 0 Then Exit Sub
        
    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}
    
    If KeyAscii = 13 Then
        Select Case dtgSI.Col
            Case 0
                If GetValueFrTable("cItemNo", "ITEM", "cItemNo = '" & Trim(dtgSI.Columns(0).Value) & "'") = "" Then
                    dtgSI_ButtonClick (0) 'use button click
                End If
            Case 1
            
            Case 2
                If cboSI.Visible = False Then
                    dtgSI_ButtonClick (2)
                    If Trim(dtgSI.Columns(2).Text) <> "" Then cboSI = Trim(dtgSI.Columns(2).Text)
    
                Else
                    SendKeys "{Tab}"
                End If
            Case 4
                If cboSI.Visible = False Then
                    dtgSI_ButtonClick (4)
                    If Trim(dtgSI.Columns(4).Text) <> "" Then cboSI = Trim(dtgSI.Columns(4).Text)
                Else
                    SendKeys "{Tab}"
                End If
            Case 6
                rsDetail!cDiscount = dtgSI.Columns(6).Text
                dtgSI_AfterColUpdate (6)
                If Not lNetOK Then
                    dtgSI.Col = 6
                    dtgSI.Columns(6).Value = rsDetail!cDiscount
                    Exit Sub
                Else
                    TBNewLine
                    dtgSI.LeftCol = 0
                End If
            Case Else
                SendKeys "{Tab}"
        End Select
    Else
        Select Case dtgSI.Col
            Case 6
                '"-" character
                If (KeyAscii = 45) And lLessAmount Then
                    KeyAscii = 0
                ElseIf KeyAscii = 45 Then
                    lLessAmount = True
                End If

                '"/" character
                If (KeyAscii = 47) And lLessPercent Then
                    KeyAscii = 0
                ElseIf KeyAscii = 47 Then
                    lLessPercent = True
                    lLessAmount = False
                Else
                    lLessPercent = False
                End If
               
                KeyAscii = ValidKeys(KeyAscii, "-/1234567890.", True)
            Case Else
                KeyAscii = Asc(UCase(Chr(KeyAscii))) 'All Upper Case String
        End Select
    End If
    
End Sub

Private Sub dtgSI_KeyUp(KeyCode As Integer, Shift As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If rsDetail.RecordCount = 0 Then Exit Sub
    Select Case dtgSI.Col
        Case 6
            If Trim(dtgSI.Columns(6).Text) = "/" Then
                dtgSI.Columns(6).Text = ""
                lLessPercent = False
            End If
    End Select
End Sub

'Right click menu popup
Private Sub dtgSI_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Mode <> AddNewEdit Then Exit Sub
    If Button = 2 Then
        dtgName = dtgSI.Name
        PopupMenu ITGLedgerMain.mnuDetail
    End If
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Dim iKey As Integer
    iKey = ToolbarIndex(KeyCode, Shift)
    If iKey <> 0 Then
        If ITGLedgerMain.tbrMain.Buttons(iKey).Enabled = True Then
            ToolbarFunction iKey
        End If
    End If
End Sub

'Set Your Object
Private Sub Form_Load()
        
    Set FrmName = Me
    FormSetup
    
    AcessBit Me, GetValueFrTable("AccessLevel", "SEC_ACCESSLEVEL", "RoleID = '" & SecUserRole & "' AND [Module] = 'BAR03'")

    lACNew = True
    lACEdit = True
    lACDelete = True
    lACPost = True
    lACCancel = True
    lACPrint = True

    Set rsHeader = New ADODB.Recordset
    Set rsDetail = New ADODB.Recordset
    
    'Load combobox values
    Call LoadComboValues(cboDocType, "cValue", "PARAMETER_USER", "WHERE cType = 'SIDOCTYPE' AND cCompanyID = '" & Trim(COID) & "'")
    Call LoadComboValues(cboTerms, "cParamName", "PARAMETER_USER", "WHERE cType = 'TERMS' AND cCompanyID = '" & Trim(COID) & "'", "nOrder")
    Call LoadComboValues(cboIntTerms, "cParamName", "PARAMETER_USER", "WHERE cType = 'TERMS' AND cCompanyID = '" & Trim(COID) & "'", "nOrder")
    Call LoadComboValues(cboPaymentType, "cValue", "PARAMETER_SYSTEM", "WHERE cType = 'SOPAYTYPE'")
    Call LoadComboValues(cboTaxType, "CValue", "PARAMETER_USER", "WHERE cType = 'TAXTYPE' AND cCompanyID = '" & Trim(COID) & "'")
    
    FormLocking True
    FormSearch True
    SearchObj True
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True

    Mode = Find
    txtInvNo.Locked = False
    
    lNetOK = True 'Boolean variable for discount computation
        
End Sub

'Activate your Toolbar Mode
Private Sub Form_Activate()
    TBBitReload
End Sub

'Release your Object
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
    If Mode = AddNewEdit Then
        MsgBox "Unable to close. You are in Add/New/Edit mode." & vbCr & _
            " Must Save or Undo", vbCritical, Me.Caption
        Cancel = True
        Exit Sub
    End If
    
    CloseMenuTab ITGLedgerMain

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , , , , , True
    BitVisible ITGLedgerMain.tbrMain
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = False
    
    Set oPrint = Nothing
    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set rsPayment = Nothing
    Set connHeader = Nothing
    Set connDetail = Nothing
    Set connPayment = Nothing
    
    Set frmBasicARCashInvoice = Nothing

    lCloseWindow = True
    
    'oForm(Me.Tag).Mode = 1
    'oForm(Me.Tag).Tag = Me.Tag
End Sub

'Add new record to the recordset
Public Sub TBNew()
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    txtInvNo.BackColor = &HE0FFFF
    Mode = AddNewEdit
    
    If rsHeader.State <> adStateOpen Then
        OpenNewConnection connHeader
        OpenNewConnection connDetail
        OpenNewConnection connPayment
        Set rsHeader = Nothing
        Set rsDetail = Nothing
        Set rsPayment = Nothing
        Set rsHeader = New ADODB.Recordset
        Set rsDetail = New ADODB.Recordset
        Set rsPayment = New ADODB.Recordset
        OpenRecordsetWithCN rsDetail, "*", "SALES_T", connDetail, "WHERE 1 = 0"
        OpenRecordsetWithCN rsHeader, "*", "SALES", connHeader, "WHERE 1 = 0"
        OpenRecordsetWithCN rsPayment, "*", "SALES_P", connPayment, "WHERE 1 = 0"
        SetDataSource
        SetDataField
    Else
        vBM = rsHeader.Bookmark
    End If
    
    rsHeader.AddNew
    rsHeader!cCompanyID = COID
    rsHeader!dDate = Date
    rsHeader!cType = "Invoice"
    rsHeader!cPayType = "Cash"
    
    txtReturns = "0.00"
    txtCredit = "0.00"
    txtDebit = "0.00"
    txtPayment = "0.00"
    txtBalance = "0.00"

    Set FrmName = Me
    FormLocking False
    ClrRequired &HC0&
    txtGross.Locked = True
    SSTab1.ActiveTab = 0
    txtInvNo.SetFocus

End Sub

'Undo all changes to the recordset
Public Sub TBUndoAll()
On Error GoTo ErrorHandler

    Mode = Normal
    
    If rsHeader.Status = adRecNew Then TBUndoCurrent
    
    rsHeader.CancelBatch adAffectAll
    rsDetail.CancelBatch adAffectAll
    rsPayment.CancelBatch adAffectAll
    
    UnbindControls
    
    If rsHeader.RecordCount <> 0 Then rsHeader.Bookmark = vBM
    
    Set FrmName = Me
    FormLocking True
    
    If rsHeader.RecordCount <> 0 Then
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , lACCancel, , , True, True, lACPrint, True
    Else
        RSZero
        Mode = Find
    End If

    sbRS.Panels(2) = ""

    SetDataSource
    SetDataField

ErrorHandler:
    cboSI.Visible = False
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoAll
    End If

End Sub

'Undo changes on the current record
Public Sub TBUndoCurrent()
On Error GoTo ErrorHandler

    GetChild
    If rsHeader.Status = adRecNew Then
        rsDetail.CancelBatch adAffectAll
        rsHeader.CancelUpdate
    Else
        rsHeader.CancelBatch adAffectCurrent
        rsDetail.CancelBatch adAffectAll
    End If
   
    If rsHeader.RecordCount = 0 Then RSZero

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoCurrent
    End If

End Sub

'Save all changes
Public Sub TBSave()
Dim OKUpdate As Boolean
Dim lNew As Boolean
On Error GoTo ErrHandler

    'Audit Trail
    lBoolean = False
    If rsHeader.Status = adRecNew Then
        lBoolean = True
            
    End If
    
    If Not MandatoryOK Then Exit Sub
    
    ComputeAll
    
    OKUpdate = False
    cn.BeginTrans
    connHeader.BeginTrans
    connDetail.BeginTrans
    connPayment.BeginTrans

    rsHeader.UpdateBatch adAffectAll
    rsDetail.UpdateBatch adAffectAll
    rsPayment.UpdateBatch adAffectAll

    cn.CommitTrans
    connPayment.CommitTrans
    connDetail.CommitTrans
    connHeader.CommitTrans
    
    OKUpdate = True
    
    Set FrmName = Me
    FormLocking True
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , lACCancel, , , True, True, lACPrint, True
    Mode = Normal
        
    TotalAmount
        
    MsgBox "Record/s successfully saved.", vbInformation, "iTG Finance Manager"
    sbRS.Panels(2) = ""

    'Audit trail
    UpdateLogFile "Sales Invoice-VS", Trim(txtInvNo), IIf(lBoolean, "Inserted", "Updated")
    
    'Update GL Activity
    UpdateGLA "Update", "SI", Trim(txtInvNo)

ErrHandler:
    cboSI.Visible = False
    cboCS_C.Visible = False
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        OKUpdate = True
        cn.RollbackTrans
        connPayment.RollbackTrans
        connDetail.RollbackTrans
        connHeader.RollbackTrans
        MsgBox "Record cannot be updated. Some values may have been changed by other user/s since last read." & vbCr & _
                "Records will be automatically refreshed. All changes made to the record will be gone upon refresh.", vbInformation, "iTG Finance Manager"
        vBookMark = rsHeader.Bookmark
        UnbindControls
        rsHeader.Requery
        rsDetail.Requery
        rsPayment.Requery
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , lACCancel, , , True, True, lACPrint, True
        Mode = Normal
        If rsHeader.RecordCount <> 0 Then
            Set FrmName = Me
            FormLocking True
            SetDataField
            SetDataSource
            rsHeader.Bookmark = vBookMark
        Else
            RSZero
        End If
    End If
    If Not OKUpdate Then
        MsgBox "Transaction update failed.", vbInformation, "iTG Finance Manager"
        cn.RollbackTrans
        connPayment.RollbackTrans
        connDetail.RollbackTrans
        connHeader.RollbackTrans
        ErrorLog err.Number, err.Description, Me.Name 'Error log
    End If
    
End Sub

'Sets the form & recorset to add/edit mode
Public Sub TBEdit()
    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled. Edit is not allowed.", vbExclamation, "iTG Finance Manager"
        Exit Sub
    End If
    If Not AllowEdit Then Exit Sub
    Mode = AddNewEdit
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    Set FrmName = Me
    FormLocking False
    ClrRequired &HC0&
    txtGross.Locked = True
    txtInvNo.Locked = True
    SSTab1.ActiveTab = 0
    dtbDate.SetFocus
    vBM = rsHeader.Bookmark

    lSysTransDate = GetValueFrTable("lTransDate", "system_autonumber", "cCode = 'AUTO_NUMBER_CI'") 'add by denz:2/17/2011
    If lSysTransDate Then
        dtbDate.Enabled = True
    Else: dtbDate.Enabled = False
    End If
End Sub

'Delete record
Public Sub TBDelete()
On Error GoTo ErrorHandler

    sID = Trim(txtInvNo)
    
    If rsHeader.RecordCount = 0 Then Exit Sub

    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled. Deletion is not allowed.", vbExclamation, "iTG Finance Manager"
        Exit Sub
    End If
    
    If MsgBox("Are you sure you want to delete this record?", vbQuestion + vbYesNo, "iTG Finance Manager") = vbNo Then Exit Sub

    If Not AllowDelete("delete") Then Exit Sub
    
    'Update GL Activity
    UpdateGLA "Delete", "SI", Trim(txtInvNo)
    
    GetChild
    If rsDetail.RecordCount <> 0 Then
        rsDetail.MoveFirst
        Do Until rsDetail.RecordCount = 0
            rsDetail.Delete adAffectCurrent
            If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
        Loop
    End If
    
    If rsPayment.RecordCount <> 0 Then
        rsPayment.MoveFirst
        Do Until rsPayment.RecordCount = 0
            rsPayment.Delete adAffectCurrent
            If rsPayment.RecordCount <> 0 Then rsPayment.MoveFirst
        Loop
    End If
    
    'Audit trail
    UpdateLogFile "Sales Invoice", Trim(txtInvNo), "Deleted"

    rsHeader.Delete adAffectCurrent
    
    rsPayment.UpdateBatch adAffectAll
    rsDetail.UpdateBatch adAffectAll
    rsHeader.UpdateBatch adAffectAll
    
    cn.Execute ("DELETE PR WHERE cCompanyID = '" & COID & "' AND cTranNo = '" & Trim(cString) & "'")
    cn.Execute ("DELETE PR_T WHERE cCompanyID = '" & COID & "' AND cTranNo = '" & Trim(cString) & "'")
    cn.Execute ("DELETE PR_C WHERE cCompanyID = '" & COID & "' AND cTranNo = '" & Trim(cString) & "'")
    cn.Execute ("DELETE PR_MAP WHERE cCompanyID = '" & COID & "' AND cTranNo = '" & Trim(cString) & "'")
        
    TBPrevRec

    Mode = Normal

    If rsHeader.RecordCount = 0 Then
        RSZero
    End If

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        cn.Execute "DELETE SALES_P WHERE cInvNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        cn.Execute "DELETE SALES_T WHERE cInvNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        cn.Execute "DELETE SALES WHERE cInvNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        Resume Next
    End If

End Sub

'Search using the frmITGSearch
Public Sub TBFind()
    Mode = Normal
    txtInvNo.Locked = True
    frmITGSearch.Show vbModal
End Sub

'Search using the recordset primary key
Public Sub TBFindPrimary()
Dim sTemp As String
If Mode = Find Then
    FormWaitShow App.Path & "\Transmit.avi", "Loading data . . ."
        
    OpenNewConnection connHeader
    OpenNewConnection connDetail
    OpenNewConnection connPayment
    
    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set rsPayment = Nothing
    Set rsHeader = New ADODB.Recordset
    Set rsDetail = New ADODB.Recordset
    Set rsPayment = New ADODB.Recordset
            
    sTemp = Trim$(GetSearchString)
    If sTemp = "ERROR" Then
        MsgBox "Only Allows A - Z, 0 - 9, '.', ',' and %(wildcard)", vbExclamation, ""
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
        txtInvNo.Locked = False
        txtInvNo.SetFocus
        Exit Sub
    End If
    
    OpenRecordsetWithCN rsHeader, "*", "SALES", connHeader, IIf(sTemp = "", "", " WHERE " & sTemp)
         
    OpenRecordsetWithCN rsDetail, "*", "SALES_T", connDetail, IIf(sTemp = "", "", " WHERE cInvNo IN (SELECT cInvNo FROM SALES WHERE " & sTemp & ")")
    
    OpenRecordsetWithCN rsPayment, "*", "SALES_P", connPayment, IIf(sTemp = "", "", " WHERE cInvNo IN (SELECT cInvNo FROM SALES WHERE " & sTemp & ")")
                    
    Set FrmName = Me
    FormLocking True
            
       If rsHeader.RecordCount = 0 Then
        FormWaitHide
        MsgBox "No matching record/s found.", vbInformation, "ComUnion Search"
        RSZero
        FormSearch True
        SearchObj True
        Mode = Find
        Exit Sub
    End If
    SetDataSource
    SetDataField
    txtInvNo.BackColor = &HE0FFFF
    Mode = Normal
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , lACCancel, , , True, True, lACPrint, True, True

    FormWaitHide
Else
    RSZero
    FormSearch True
    SearchObj True
    Mode = Find

End If

End Sub

'Reload menu buttons (do not delete this sub)
Public Sub TBBitReload()
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True
    BitReload ITGLedgerMain, Me, ITGLedgerMain.tbrMain, sBit
    Set FrmName = Me
    dtgName = dtgSI.Name
End Sub

'Close active window
Public Sub TBCloseWindow()
    Unload Me
End Sub

'Move first
Public Sub TBFirstRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveFirst rsHeader
    
End Sub

'Move previuos
Public Sub TBPrevRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MovePrevious rsHeader
    
End Sub

'Move next
Public Sub TBNextRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveNext rsHeader
    
End Sub

'Move last
Public Sub TBLastRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveLast rsHeader
    
End Sub

'Add new line to the detail recordset
Public Sub TBNewLine()
    
    If rsHeader!cInvNo = "" Then Exit Sub
    
    If dtgName = "dtgSI" Then
        rsDetail.AddNew
        rsDetail!cCompanyID = COID
        rsDetail!cInvNo = Trim(rsHeader!cInvNo)
        dtgSI.Col = 0
        GetChild
        If rsDetail.RecordCount <> 0 Then rsDetail.MoveLast
        dtgSI.Col = 0
        dtgSI.Columns(0).Value = ""
        dtgSI.SetFocus
    ElseIf dtgName = "dtgPayment" Then
        TotalAmount
        If nAmount = nPAmount Then Exit Sub
        If rsDetail.RecordCount <= 0 Then
            MsgBox "Detail(s) of this invoice is mandatory.", vbCritical, msgTtl
            dtgSI.SetFocus
            Exit Sub
        End If
        rsPayment.AddNew
        rsPayment!cCompanyID = COID
        rsPayment!cInvNo = Trim(txtInvNo.Text)
        rsPayment!dDate = Trim(dtbDate.Text)
        dtgPayment.Col = 0
        GetChild
        If rsPayment.RecordCount <> 0 Then rsPayment.MoveLast
        dtgPayment.Col = 0
        dtgPayment.Columns(0).Value = ""
        dtgPayment.SetFocus
    End If
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True

End Sub

'Delete line in the detail recordset
Public Sub TBDeleteLine()
On Error GoTo ErrorHandler
    
    If dtgName = "dtgSI" Then
        If rsDetail.RecordCount = 0 Then Exit Sub
        vBookMark = dtgSI.Bookmark
        GetChild
        dtgSI.Bookmark = vBookMark
        rsDetail.Delete adAffectCurrent
        ComputeAll
    ElseIf dtgName = "dtgPayment" Then
        If rsPayment.RecordCount = 0 Then Exit Sub
        vBookMark = dtgPayment.Bookmark
        GetChild
        dtgPayment.Bookmark = vBookMark
        rsPayment.Delete adAffectCurrent
    End If
    GetChild
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    
ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Undo All
Public Sub TBUndoLineAll()
On Error GoTo ErrorHandler

    If dtgName = "dtgSI" Then
        rsDetail.CancelBatch adAffectAll
    ElseIf dtgName = "dtgPayment" Then
        rsDetail.CancelBatch adAffectAll
    End If

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Undo current line
Public Sub TBUndoLineCurrent()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Post current record
Public Sub TBPostRecord()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Cancel current record
Public Sub TBCancelRecord()
On Error GoTo ErrorHandler
    
    If rsHeader.RecordCount = 0 Then Exit Sub

    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled.", vbExclamation, "iTG Finance Manager"
        Exit Sub
    End If
    
    If MsgBox("Are you sure you want to cancel this record?", vbQuestion + vbYesNo, "iTG Finance Manager") = vbNo Then Exit Sub

    If Not (AllowDelete("cancel")) Then Exit Sub
    
    'Audit trail
    UpdateLogFile "Sales Invoice", Trim(txtInvNo), "Cancelled"

    'Update GL Activity
    UpdateGLA "Delete", "SI", Trim(txtInvNo)
    
    cn.Execute ("UPDATE SALES SET lCancelled = 1 WHERE cInvNo = '" & Trim(txtInvNo) & "' AND cCompanyID = '" & COID & "'")
    
    sbRS.Panels(5) = "CANCELLED"
    Mode = Normal
    
    rsHeader!lCancelled = True
    rsHeader.UpdateBatch adAffectAll

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Print
Public Sub TBPrintRecord()
    If Trim(txtInvNo) = "" Then Exit Sub
    RepName = "Sales_Invoice_Trans"
    cModule = "Sales_Invoice"
    oPrint.PrintReceipt Trim(txtInvNo)
End Sub

'Sets the data source of the controls
Sub SetDataSource()
    Set FrmName = Me
    BindControls rsHeader
    Set dtgList.DataSource = rsHeader
    Set dtgSI.DataSource = rsDetail
    Set txtLongDesc.DataSource = rsDetail
    Set dtgPayment.DataSource = rsPayment
      
End Sub
    
'Sets the data field for every bounded controls
Sub SetDataField()
    With rsHeader
        txtInvNo.DataField = !cInvNo
        dtbDate.DataField = !dDate
        txtCode.DataField = !cCode
        txtMSCode.DataField = !cMSCode
        txtPDCode.DataField = !cPDCode
        txtSMCode.DataField = !cSMan
        txtPCCode.DataField = !cPCCode
        txtRemarks.DataField = "cRemarks"
        txtIntTerms.DataField = !cIntTerm
        txtTerms.DataField = !cTerm
        txtPaymentType.DataField = !cPayType
        txtGross.DataField = !nGross
        'txtType.DataField = !cType
        txtDocType.DataField = !cdoctype
        
    End With
End Sub


Private Sub rsHeader_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
On Error GoTo ErrorHandler
    
    If Not (rsHeader.EOF) Or Not (rsHeader.BOF) Then
        'Status bar setup
        sbRS.Panels(1) = "Record: " & IIf((rsHeader.AbsolutePosition = -2), "0", rsHeader.AbsolutePosition) & "/" & rsHeader.RecordCount
        
        If rsHeader.Status <> adRecNew Then
            txtInvNo.Locked = True
        Else
            txtInvNo.Locked = False
        End If
        
        If Mode = AddNewEdit Then
            Select Case rsHeader.Status
                Case adRecNew
                    sbRS.Panels(2) = "New"
                Case adRecModified
                    sbRS.Panels(2) = "Modified"
                Case Else
                    sbRS.Panels(2) = ""
            End Select
        Else
            sbRS.Panels(2) = ""
        End If
        
        GetChild
        ShowInvoiceBalance
    
        If rsHeader!lCancelled = True Then
            sbRS.Panels(4) = rsHeader!cCRemarks
            sbRS.Panels(5) = "CANCELLED"
        Else
            sbRS.Panels(4) = ""
            sbRS.Panels(5) = ""
        End If
            
    Else
        sbRS.Panels(1) = "Record: 0/0"
        sbRS.Panels(2) = ""
        txtInvNo.Locked = False
    End If
    
    If Mode = AddNewEdit Then
        dtgSI.Refresh
    End If
    
ErrorHandler:
    'Err.Number -2147217885
    'Description - Row handle referred to a deleted row or a row marked for deletion.
    If err.Number = -2147217885 Then
        Resume Next
    End If
    
End Sub

Private Sub Timer1_Timer()
    If Mode = AddNewEdit Then
        SSTab1.TabEnabled(1) = False
    Else
        SSTab1.TabEnabled(1) = True
    End If
End Sub

Private Sub txtCode_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtName) = "" And Trim(txtCode) <> "" Then cmdPickCode_Click
End Sub

Private Sub txtDocType_Change()
    If Trim(txtDocType) <> "" Or txtDocType <> vbNullString Then
        If GetValueFrTable("cValue", "PARAMETER_USER", "cType = 'SIDOCTYPE' AND cValue = '" & Trim(txtDocType) & "' ", False) <> "" Then
            cboDocType = Trim(txtDocType)
        Else: cboDocType.ListIndex = -1
        End If
    Else: cboDocType.ListIndex = -1
    End If
End Sub


Private Sub txtLongDesc_KeyPress(KeyAscii As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}
    KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub txtLongDesc_LostFocus()
    txtLongDesc.Visible = False
    dtgSI.Col = 2
    dtgSI.SetFocus
End Sub

Private Sub txtMSCode_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtMSDesc) = "" And Trim(txtMSCode) <> "" Then cmdPickMS_Click
End Sub

Private Sub txtPaymentType_Change()
    If Trim(txtPaymentType) <> "" Or txtPaymentType <> vbNullString Then
        cboPaymentType = Trim(txtPaymentType)
    Else
        cboPaymentType.ListIndex = -1
    End If
End Sub

Private Sub txtPCCode_Change()
    txtPCDesc = GetValueFrTable("cDescription", "PROFITCENTER", "cPCCode = '" & Trim(txtPCCode) & "'")
End Sub

Private Sub txtPCCode_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtPCDesc) = "" And Trim(txtPCCode) <> "" Then cmdPickPC_Click
End Sub

Private Sub txtPDCode_Change()
    txtPDDesc = ""
    txtPDDesc = GetValueFrTable("cDescription", "CLASSIFICATION", "cClassCode = '" & Trim(txtPDCode) & "' AND cType = 'PD'")
End Sub

Private Sub txtPDCode_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtPDDesc) = "" And Trim(txtPDCode) <> "" Then cmdPickPD_Click
End Sub

Private Sub txtSMCode_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtSMName) = "" And Trim(txtSMCode) <> "" Then cmdPickSM_Click
End Sub

Private Sub txtInvNo_LostFocus()
    'Does Code Already exists
    If Mode = AddNewEdit Then
        If Trim(txtInvNo) = "" Then
            MsgBox "Empty primary input.", vbInformation, "iTG Finance Manager"
            PreviousTab frmComUnionMenuTab
            txtInvNo.SetFocus
        Else
            If rsHeader.Status <> adRecNew Then Exit Sub
            txtInvNo = Trim(txtInvNo)
            If IDExisting(rsHeader, "cInvNo", "SALES", Trim(rsHeader!cInvNo)) Then
                MsgBox "Sales Invoice No. already exists.", vbInformation, "iTG Finance Manager"
                PreviousTab frmComUnionMenuTab
                txtInvNo.SetFocus
            End If
        End If
    End If
End Sub

Private Sub txtCode_Change()
    txtName = ""
    txtName = GetValueFrTable("cName", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtCode) & "'")
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtName) <> "" Then
        
        Set rs = New ADODB.Recordset
        
        sSQL = "select cMSCode, cPDCode, cSMan, cTerm, cIntTerm from CLIENT_CUSTOMER where cCode = '" & Trim(txtCode) & "' "
        rs.Open sSQL, cn, adOpenKeyset, adLockReadOnly
        
        rsHeader!cMSCode = rs!cMSCode
        rsHeader!cPDCode = rs!cPDCode
        rsHeader!cSMan = rs!cSMan
        rsHeader!cTerm = rs!cTerm
        rsHeader!cIntTerm = rs!cIntTerm
        
        rs.Clone
        Set rs = Nothing
    Else
        txtMSCode = ""
        txtPDCode = ""
        txtSMCode = ""
        cboTerms.ListIndex = -1
        cboIntTerms.ListIndex = -1
    End If
End Sub

Private Sub txtIntTerms_Change()
    If Trim(txtIntTerms) <> "" Or txtIntTerms <> vbNullString Then
        cboIntTerms = Trim(txtIntTerms)
    Else
        cboIntTerms.ListIndex = -1
    End If
End Sub

Private Sub txtMSCode_Change()
    txtMSDesc = ""
    txtMSDesc = GetValueFrTable("cDescription", "CLASSIFICATION", "cClassCode = '" & Trim(txtMSCode) & "' AND cType = 'MS'")
End Sub

Private Sub txtSMCode_Change()
    txtSMName = ""
    txtSMName = GetValueFrTable("cName", "SALESMAN", "cCode = '" & Trim(txtSMCode) & "'")
End Sub


Private Sub txtTerms_Change()
    If Trim(txtTerms) <> "" Or txtTerms <> vbNullString Then
        cboTerms = Trim(txtTerms)
    Else
        cboTerms.ListIndex = -1
    End If
End Sub

'Check if all mandatory fields are complete
Function MandatoryOK() As Boolean
    
    MandatoryOK = True

    If Trim(txtInvNo) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Invoice Number' is mandatory. Null value is not allowed.", vbInformation, "iTG Finance Manager"
        txtInvNo.SetFocus
        Exit Function
    End If
    
    If rsHeader.Status = adRecNew Then
        If IDExisting(rsHeader, "cInvNo", "SALES", Trim(rsHeader!cInvNo)) Then
            MandatoryOK = False
            MsgBox "Sales invoice No. already exist.", vbInformation, "iTG Finance Manager"
            txtInvNo.SetFocus
            Exit Function
        End If
    End If

    'Required fields
    If Trim(dtbDate.Text) = "__/__/____" Then
        MandatoryOK = False
        MsgBox "Field 'Transaction Date' is mandatory. Null value is not allowed.", vbInformation, "iTG Finance Manager"
        dtbDate.SetFocus
        Exit Function
    ElseIf Trim(txtCode) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Customer' is mandatory. Null value is not allowed.", vbInformation, "iTG Finance Manager"
        txtCode.SetFocus
        Exit Function
    ElseIf Trim(txtMSCode) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Market Segment' is mandatory. Null value is not allowed.", vbInformation, "iTG Finance Manager"
        txtMSCode.SetFocus
        Exit Function
    ElseIf Trim(txtSMCode) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Salesman' is mandatory. Null value is not allowed.", vbInformation, "iTG Finance Manager"
        txtSMCode.SetFocus
        Exit Function
    ElseIf Trim(txtIntTerms) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Internal Terms' is mandatory. Null value is not allowed.", vbInformation, "iTG Finance Manager"
        cboIntTerms.SetFocus
        Exit Function
    ElseIf Trim(txtTerms) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Actual Terms' is mandatory. Null value is not allowed.", vbInformation, "iTG Finance Manager"
        cboTerms.SetFocus
        Exit Function
    ElseIf Trim(txtPaymentType) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Payment Type' is mandatory. Null value is not allowed.", vbInformation, "iTG Finance Manager"
        cboPaymentType.SetFocus
        Exit Function
    End If
    
    GetChild
    
    'Transaction without details
    If rsDetail.RecordCount = 0 Then
        MandatoryOK = False
        MsgBox "Cannot save transaction without details.", vbInformation, "iTG Finance Manager"
        dtgSI.SetFocus
        Exit Function
    End If
    
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        If rsDetail.Status = (adRecNew) Or rsDetail.Status = (adRecModified) Then
            If IsNull(rsDetail!cItemNo) Then
                rsDetail.Delete
            ElseIf Trim(rsDetail!cItemNo) = "" Then
                rsDetail.Delete
            Else
                rsDetail.MoveNext
            End If
        Else
            rsDetail.MoveNext
        End If
    Loop
    
    If rsPayment.RecordCount <> 0 Then rsPayment.MoveFirst
    Do Until rsPayment.EOF
        If rsPayment.Status = (adRecNew) Or rsPayment.Status = (adRecModified) Then
            If IsNull(rsPayment!cType) Then
                rsPayment.Delete
            ElseIf Trim(rsPayment!cType) = "" Then
                rsPayment.Delete
            Else
                rsPayment.MoveNext
            End If
            
            If IsNull(rsPayment!nCash) Then
                rsPayment.Delete
            End If
        Else
            rsPayment.MoveNext
        End If
    Loop
    GetChild

    If rsDetail.RecordCount < 1 Then
        MsgBox "Cannot save transaction without details.", vbExclamation, "iTG Finance Manager"
        MandatoryOK = False
        Exit Function
    End If

End Function

'Filter detail recordset to header's primary
Private Sub GetChild()
    rsDetail.Filter = "cInvNo = '" & Trim(rsHeader!cInvNo) & "'"
    rsPayment.Filter = "cInvNo = '" & Trim(rsHeader!cInvNo) & "'"
End Sub

'Sets the form if record number is zero
Private Sub RSZero()
    sbRS.Panels(1) = "Record: 0/0"
    sbRS.Panels(2) = ""
    sbRS.Panels(4) = ""
    sbRS.Panels(5) = ""
    
    Set dtgSI.DataSource = Nothing
    dtgSI.Refresh
    
    Set FrmName = Me
    UnbindControls
    TextClearing
    FormLocking True
    
    If rsHeader.State = adStateOpen Then rsHeader.Close
    If rsDetail.State = adStateOpen Then rsDetail.Close
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
    
    txtInvNo.Locked = False
    txtInvNo.SetFocus
    
    Mode = Find
End Sub

Sub SearchObj(lEnable As Boolean)
    dtbDate.Enabled = lEnable
    cmdPickCode.Enabled = lEnable
    cmdPickMS.Enabled = lEnable
    cmdPickPD.Enabled = lEnable
    cmdPickSM.Enabled = lEnable
    cboIntTerms.Enabled = lEnable
    cboTerms.Enabled = lEnable
    cboPaymentType.Enabled = lEnable
    cboTaxType.Enabled = lEnable
End Sub

'Gets initital item values
Private Sub GetInitialItemValues()
    rsDetail!cDesc = Trim(GetValueFrTable("cDesc", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")) & ""
    rsDetail!cUnit = Trim(GetValueFrTable("cUnit", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")) & ""
    rsDetail!nUDPrice = Trim(GetValueFrTable("nSRPrice", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")) & ""
    GetCustFromPM
    
    rsDetail!nAmount = 0
    rsDetail!nCost = IIf(GetValueFrTable("nAveCost", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'") = "", 0, GetValueFrTable("nAveCost", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'"))
    rsDetail!cCosting = "Average"
                
    aQty(rsDetail.AbsolutePosition) = rsDetail!nQty & 0
    rsDetail!nPrice = rsDetail!nUDPrice * rsDetail!nQty & 0
    
    ComputeAll
    

End Sub

Private Function GetSearchString() As String
On Error GoTo ErrorHandler
Dim sWhere As String

    GetSearchString = True

    If Trim$(txtInvNo.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cInvNo LIKE '" & Trim$(txtInvNo.Text) & "%'"
    End If

    If Trim$(dtbDate.Text) <> "__/__/____" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " dDate = '" & Trim$(dtbDate.Text) & "'"
    End If
    
    If Trim$(txtCode.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cCode LIKE '" & Trim$(txtCode.Text) & "%'"
    End If
    
    If Trim$(txtMSCode.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cMSCode LIKE '" & Trim$(txtMSCode.Text) & "%'"
    End If
    
    If Trim$(txtPDCode.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cPDCode LIKE '" & Trim$(txtPDCode.Text) & "%'"
    End If
    
    If Trim$(txtSMCode.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cSMan LIKE '" & Trim$(txtSMCode.Text) & "%'"
    End If
    
    If Trim(txtIntTerms.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cIntTerm LIKE '" & Trim$(txtIntTerms.Text) & "%'"
    End If
    
    If Trim(txtTerms.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cTerm LIKE '" & Trim$(txtTerms.Text) & "%'"
    End If
    
    If Trim(txtPaymentType.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cPayType LIKE '" & Trim$(txtPaymentType.Text) & "%'"
    End If
    
    GetSearchString = Trim$(sWhere)

    Exit Function
ErrorHandler:
    GetSearchString = "ERROR"
End Function

Private Sub ComputeAll()
Dim n, m, d As Double
Dim sDisc As String

    If (rsDetail.EOF Or rsDetail.BOF) And rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    
    vBookMark = rsDetail.Bookmark
    
    If rsDetail.RecordCount <> 0 Then
        rsDetail.MoveFirst
        
        
        Do Until rsDetail.EOF
        
            Do While (Right(rsDetail!cDiscount, 1) = "-" Or Right(rsDetail!cDiscount, 1) = "/")
                rsDetail!cDiscount = Mid(rsDetail!cDiscount, 1, Len(rsDetail!cDiscount) - 1)
            Loop
            
            Do While Left(rsDetail!cDiscount, 1) = "/"
                rsDetail!cDiscount = Mid(rsDetail!cDiscount, 2, Len(rsDetail!cDiscount))
            Loop
                
            sDisc = IIf(IsNull(rsDetail!cDiscount), "", rsDetail!cDiscount)
            
            rsDetail!nUDPrice = IIf(IsNull(rsDetail!nUDPrice), 0, rsDetail!nUDPrice)
            rsDetail!nQty = IIf(IsNull(rsDetail!nQty), 0, rsDetail!nQty)
            rsDetail!nPrice = ComputedDiscount(rsDetail!nUDPrice, sDisc)
            
            rsDetail!nAmount = rsDetail!nQty * rsDetail!nPrice
            d = d + ((rsDetail!nUDPrice - rsDetail!nPrice) * rsDetail!nQty)
            m = m + (rsDetail!nUDPrice * rsDetail!nQty)
            n = n + (rsDetail!nPrice * rsDetail!nQty)
            rsDetail.MoveNext
        Loop
    End If
    rsDetail.Bookmark = vBookMark
    
    rsHeader!nGross = n
    'rsHeader!nNet = n
    rsHeader!nDiscount = d
End Sub

Private Function ComputedDiscount(Base As Double, Discount As String) As Double

Dim si As Integer
Dim s(0 To 50), ns, sString As String
Dim lStop As Boolean

    ComputedDiscount = Base
    
    If Discount <> "" Then
        si = 0
        For i = 1 To Len(Discount)
            sString = Mid(Discount, i, 1)
            If sString <> "/" Then
                ns = ns + sString
                s(si) = ns
            Else
                si = si + 1
                ns = ""
            End If
        Next i
            
        si = 0
        lStop = False
        
        Do While Not lStop
            If s(si) <> "" Then
                If Not IsNumeric(s(si)) Or Right(s(si), 1) = "-" Then
                    MsgBox "Invalid discount format.", vbInformation, msgTtl
                    ComputedDiscount = 0
                    Exit Function
                End If
                
                If Left(s(si), 1) = "-" Then
                    ComputedDiscount = Round(ComputedDiscount + CDbl(s(si)), 2)
                Else
                    ComputedDiscount = Round(ComputedDiscount - (ComputedDiscount * (CDbl(s(si)) * 0.01)), 2)
                End If
                
                si = si + 1
            Else
                lStop = True
            End If
        Loop
                
    End If

End Function

Private Function AllowEdit() As Boolean
    AllowEdit = True
    
    'Cannot edit if transaction already has a collection reference
    If GetValueFrTable("cInvNo", "PR_T", "cInvNo = '" & Trim(rsHeader!cInvNo) & "'") <> "" Then
        MsgBox "Cannot edit transaction with collection.", vbCritical + vbExclamation, "iTG Finance Manager"
        AllowEdit = False
        Exit Function
    End If
    
End Function

Private Function AllowDelete(sAction As String) As Boolean
    AllowDelete = True
    
    'Cannot delete if transaction already has a collection reference
    If GetValueFrTable("cInvNo", "PR_T", "cInvNo = '" & Trim(rsHeader!cInvNo) & "'") <> "" Then
        MsgBox "Cannot " & sAction & " transaction with collection.", vbCritical + vbExclamation, "iTG Finance Manager"
        AllowDelete = False
        Exit Function
    End If
    
End Function

'Compute the Qty according to unit
Function GetActualUnitQty(OrigQty As Double, ItemNo As String, CurrentUnit As String) As Double
Dim nUnitQty As Double

    nUnitQty = GetValueFrTable("nFactor", "ITEM_UNIT", "cItemNo = '" & ItemNo & "' AND cUnit = '" & CurrentUnit & "'")
    
    If nUnitQty = 0 Then
        GetActualUnitQty = OrigQty
        nSRP(rsDetail.AbsolutePosition) = GetValueFrTable("nSRPrice", "ITEM", "cItemNo = '" & ItemNo & "' AND cUnit = '" & CurrentUnit & "'")
        nWSP(rsDetail.AbsolutePosition) = GetValueFrTable("nWSPrice", "ITEM", "cItemNo = '" & ItemNo & "' AND cUnit = '" & CurrentUnit & "'")
        nNewQtyBoundary(rsDetail.AbsolutePosition) = 0
    Else
        GetActualUnitQty = Fix(OrigQty / nUnitQty)
        nSRP(rsDetail.AbsolutePosition) = GetValueFrTable("nSRPrice", "ITEM_UNIT", "cItemNo = '" & ItemNo & "' AND cUnit = '" & CurrentUnit & "'")
        nWSP(rsDetail.AbsolutePosition) = GetValueFrTable("nWSPrice", "ITEM_UNIT", "cItemNo = '" & ItemNo & "' AND cUnit = '" & CurrentUnit & "'")
        nNewQtyBoundary(rsDetail.AbsolutePosition) = Fix(OrigQty / nUnitQty)
    End If
    
End Function


'Show the balances of each sales invoice
'Binding of the textboxex was disabled
Private Sub ShowInvoiceBalance()
Dim rsBalance As New Recordset

    If Mode = AddNewEdit Then Exit Sub
    
        sSQL = "SELECT *, ISNULL((nSales - nReturns - nPaid - nCredit + nDebit), 0) AS nBalance " & _
                "FROM V_SalesBalanceInquiry WHERE cInvNo = '" & rsHeader!cInvNo & "' AND cCompanyID = '" & COID & "'"
        rsBalance.Open sSQL, cn, adOpenForwardOnly, adLockReadOnly
        
        txtDebit = 0
        txtCredit = 0
        txtReturns = 0
        txtPayment = 0
        txtBalance = 0
        
        If rsBalance.RecordCount <> 0 Then
            txtDebit = rsBalance!nDebit
            txtCredit = rsBalance!nCredit
            txtReturns = rsBalance!nReturns
            txtPayment = rsBalance!nPaid
            txtBalance = rsBalance!nBalance
        End If
        
    Set rsBalance = Nothing

End Sub
'Is check Authorization code?
Function AuthorExisting(Authorization As String, Bank As String, _
            rsExist As ADODB.Recordset, Optional FromDB As Boolean) As Boolean
On Error GoTo err

Dim rsClone As New ADODB.Recordset
Set rsClone = New ADODB.Recordset
    AuthorExisting = False
    
    If FromDB Then
        sSQL = "SELECT cAuthorization FROM CREDIT_CARD WHERE cAuthorization = '" & Authorization & "' AND cBankID = '" & Bank & "' AND cCompanyID = '" & COID & "'"
    
        Set rs = New Recordset
        rs.Open sSQL, cn, adOpenForwardOnly, adLockReadOnly
        
        If rs.RecordCount <> 0 Then
            AuthorExisting = True
            Set rs = Nothing
            Exit Function
        End If
        Set rs = Nothing
    End If
    
    Set rsClone = rsExist.Clone
    
    rsClone.Filter = "cAuthorization = '" & Authorization & "' AND cBankID = '" & Bank & "'"
    
    If FromDB Then
        If rsClone.RecordCount > 1 Then
            AuthorExisting = True
        End If
    Else
        If rsClone.RecordCount >= 1 Then
            AuthorExisting = True
        End If
    End If
    
    Set rsClone = Nothing
err:
    If err.Number = 91 Then
    End If
End Function

'Is check existing?
Function CheckExisting(CheckNo As String, Bank As String, TranNo As String, _
            rsExist As ADODB.Recordset, Optional FromDB As Boolean) As Boolean

Dim rsClone As New ADODB.Recordset

    CheckExisting = False
    
    If FromDB Then
        sSQL = "SELECT cCheckNo FROM CHECKS WHERE cCheckNo = '" & CheckNo & "' AND cBankID = '" & Bank & "' AND cCompanyID = '" & COID & "'"
        Set rs = New Recordset
        rs.Open sSQL, cn, adOpenForwardOnly, adLockReadOnly
        
        If rs.RecordCount <> 0 Then
            CheckExisting = True
            Set rs = Nothing
            Exit Function
        End If
        Set rs = Nothing
    End If
    
    Set rsClone = rsExist.Clone
    
    rsClone.Filter = "cCheckNo = '" & CheckNo & "' AND cBankID = '" & Bank & "' AND cInvNo = '" & Trim(txtInvNo) & "'"
    
    If FromDB Then
        If rsClone.RecordCount > 1 Then
            CheckExisting = True
        End If
    Else
        If rsClone.RecordCount >= 1 Then
            CheckExisting = True
        End If
    End If
    
    Set rsClone = Nothing
    
End Function

'Inserts into PR & PR_T & PR_C & PR_MAP tables
Private Function SalesReciept() As Boolean
Dim rsPR As New ADODB.Recordset
Dim rsPR_T As New ADODB.Recordset
Dim rsPR_C As New ADODB.Recordset
Dim rsPR_MAP As New ADODB.Recordset
Dim sTran As String

    cString = "OR-" & Trim$(rsHeader!cInvNo)
    
    'FOR REVISION [DO NOT DELETE BECAUSE OF THE IDENTITY] ???????????
    cn.Execute ("DELETE PR WHERE cCompanyID = '" & COID & "' AND cTranNo = '" & Trim(cString) & "'")
    cn.Execute ("DELETE PR_T WHERE cCompanyID = '" & COID & "' AND cTranNo = '" & Trim(cString) & "'")
    cn.Execute ("DELETE PR_C WHERE cCompanyID = '" & COID & "' AND cTranNo = '" & Trim(cString) & "'")
    cn.Execute ("DELETE PR_MAP WHERE cCompanyID = '" & COID & "' AND cTranNo = '" & Trim(cString) & "'")
    
    GetChild
    
    OpenRecordset rsPR, "*", "PR", "WHERE 1 = 0"
    OpenRecordset rsPR_T, "*", "PR_T", "WHERE 1 = 0"
    OpenRecordset rsPR_C, "*", "PR_C", "WHERE 1 = 0"
    OpenRecordset rsPR_MAP, "*", "PR_MAP", "WHERE 1 = 0"
    
    TotalPay
    
    With rsPR
        .AddNew
            !cCompanyID = COID
            !cTranNo = cString
            !cCode = txtCode.Text
            !dDate = dtbDate.Text
            !nCash = rsPayment!nAmount
            !nInvTotal = rsHeader!nGross
            !nPayTotal = nPaid
    End With

    Do While Not rsPayment.EOF
        With rsPR_T
            .AddNew
            !cCompanyID = COID
            !cTranNo = cString
            !cInvNo = Trim(txtInvNo.Text)
            !dInvDate = dtbDate.Text
            !nInvBalance = rsHeader!nGross - rsPayment!nAmount
            !nApplied = rsPayment!nAmount
            !nEWT = 0
            !nDiscount = 0
            !nEVAT = 0
        End With
        rsPayment.MoveNext
    Loop
    rsPayment.MoveFirst
    Do While Not rsPayment.EOF
        With rsPR_C
            .AddNew
            !cCompanyID = COID
            !cTranNo = cString
            !cType = rsPayment!cType
            !cBankID = rsPayment!cBankID
            !cCheckNo = rsPayment!cCCardNo
            !dCheckDate = rsPayment!dDate
            !nAmount = rsPayment!nAmount
        End With
        rsPayment.MoveNext
    Loop
    
    With rsPR_MAP
            .AddNew
            !cCompanyID = COID
            !cTranNo = cString
            !cInvNo = Trim(txtInvNo.Text)
            !nAmount = rsHeader!nGross
    End With

    
    rsPR.UpdateBatch adAffectAll
    rsPR_T.UpdateBatch adAffectAll
    rsPR_C.UpdateBatch adAffectAll
    rsPR_MAP.UpdateBatch adAffectAll
    
    Set rsPR = Nothing
    Set rsPR_T = Nothing
    Set rsPR_C = Nothing
    Set rsPR_MAP = Nothing
    
End Function

'Inserts into PR & PR_T & PR_C & PR_MAP tables
Private Function SaveCreditCard() As Boolean
Dim rsCC As New ADODB.Recordset
Dim sTran, sType As String

cString = Trim$(rsHeader!cInvNo)

cn.Execute ("DELETE CREDIT_CARD WHERE cCompanyID = '" & COID & "' AND nRefNo = '" & Trim(cString) & "'")

GetChild
    
    OpenRecordset rsCC, "*", "CREDIT_CARD", "WHERE 1 = 0"
    
    Do While Not rsPayment.EOF
        If rsPayment!cType = "CC" Then
        With rsCC
            .AddNew
            !cCompanyID = COID
            !cAuthorization = rsPayment!cAuthorization
            !nRefNo = cString
            !cCType = rsPayment!cCCardType
            !cCode = rsHeader!cCode
            !cName = txtName.Text
            !cBankID = rsPayment!cBankID
            !cBankName = GetValueFrTable("cBankName", "BANK", " cBankID = '" & rsPayment!cBankID & "'")
            !cCCardNo = rsPayment!cCCardNo
            !dExpiration = rsPayment!dExpiration
            !nAmount = rsPayment!nAmount
        End With
        End If
        rsPayment.MoveNext
    Loop
    
    rsCC.UpdateBatch adAffectAll
    
    Set rsCC = Nothing
End Function

Private Sub GetCustFromPM()
On Error GoTo err  'jomz

Dim rsCust As New ADODB.Recordset
Dim connCust As New ADODB.Connection

OpenNewConnection connCust

'if reference in price matrix is equal to customer code (set as default price and discount for subjected item)
If GetValueFrTable("cReference", "PM a inner join pm_t b ON b.cCompanyID = a.cCompanyID AND b.cPMID = a.cPMID ", "cItemNo = '" & rsDetail!cItemNo & "' and dEffectDate <= '" & Date & "' and lCancelled = 0 and a.cCompanyID = '" & COID & "' and a.cType = 'Customer' and a.lPosted = 1 and a.lApproved = 1", True) = rsHeader!cCode Then
    rsDetail!cPricing = "Pricing Client"
    rsDetail!nUDPrice = GetValueFrTable("nPrice", "PM a inner join pm_t b ON b.cCompanyID = a.cCompanyID AND b.cPMID = a.cPMID ", "cItemNo = '" & rsDetail!cItemNo & "' and dEffectDate <= '" & Date & "' and lCancelled = 0 and a.cCompanyID = '" & COID & "' and lPosted = 1 and lApproved = 1", True)
    rsDetail!cDiscount = GetValueFrTable("cDiscount", "PM a inner join pm_t b ON b.cCompanyID = a.cCompanyID AND b.cPMID = a.cPMID ", "cItemNo = '" & rsDetail!cItemNo & "' and dEffectDate <= '" & Date & "' and lCancelled = 0 and a.cCompanyID = '" & COID & "' and lPosted = 1 and lApproved = 1", True)
Exit Sub 'exit when true
End If

'get customer type if is member of wholesaler
If GetValueFrTable("cCustomerType", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'", True) = "Member" Then
    
    If IsNull(rsDetail!cPricing) Then
        'set pricing to customer type
        rsDetail!cPricing = GetValueFrTable("cCustomerType", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'", True)
    End If
    
    sSQL = "Select nPrice,cDiscount from PM_T a inner join pm b " _
            & "ON b.cCompanyID = a.cCompanyID AND b.cPMID = a.cPMID " _
            & "where cReference = '" & GetValueFrTable("cCustomerType", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'", True) & "' and cItemNo = '" & rsDetail!cItemNo & "' " _
            & "and dEffectDate <= '" & Date & "' and lCancelled = 0 and b.cCompanyID = '" & COID & "' and b.lPosted = 1 and b.lApproved = 1"
    
    rsCust.Open sSQL, connCust, adOpenStatic, adLockOptimistic
    
    If rsCust.RecordCount = 0 Or (rsDetail!cPricing <> GetValueFrTable("cCustomerType", "CLIENT_CUSTOMER", "cCode = '" & rsHeader!cCode & "'", True)) Then
        rsDetail!nUDPrice = 0
        rsDetail!cDiscount = ""
    Else
        rsDetail!nUDPrice = rsCust!nPrice
        rsDetail!cDiscount = rsCust!cDiscount
    End If
Else
    rsDetail!cPricing = "SRP"
    Exit Sub
End If
err: Exit Sub
End Sub

Private Sub TotalPay()
    Dim rsTPay As New ADODB.Recordset
    Dim connTPay As New ADODB.Connection
    
    OpenNewConnection connTPay
    
    sSQL = "SELECT SUM(nAmount) as nAmount FROM SALES_P WHERE cInvNo = '" & Trim(txtInvNo.Text) & "'"
    
    rsTPay.Open sSQL, connTPay, adOpenStatic, adLockOptimistic
    
    nPaid = rsTPay!nAmount

End Sub

Private Sub TotalAmount()
    On Error Resume Next
    nAmount = 0
    nPAmount = 0
    nCash = 0
    
    If rsPayment.RecordCount > 0 Then
        rsPayment.MoveFirst
        Do While Not rsPayment.EOF
            nPAmount = nPAmount + rsPayment!nAmount
            rsPayment.MoveNext
        Loop
    End If
    rsPayment.MoveLast
    
    If rsPayment.RecordCount > 0 Then
        rsPayment.MoveFirst
        Do While Not rsPayment.EOF
            nCash = nCash + rsPayment!nCash
            rsPayment.MoveNext
        Loop
    End If
    rsPayment.MoveLast
    
    rsDetail.MoveFirst
    Do While Not rsDetail.EOF
        nAmount = nAmount + rsDetail!nAmount
        rsDetail.MoveNext
    Loop
        rsDetail.MoveLast
End Sub

Public Sub TBAccountAffected()
    If rsHeader!lCancelled = 0 Then
        RepName = "SALES"
        frmAccountAffected.mModuleType = KSALES
        frmAccountAffected.mRefPK = txtInvNo.Text
        frmAccountAffected.Show vbModal
    End If
End Sub
